package com.shujia.scala

object Demo7Extends {
  def main(args: Array[String]): Unit = {

    val b = new B("001", "李四", "男")
    println(b)
  }

}


class A(id: String, name: String) {
  println("A的默认构造函数")
  val _id: String = id
  val _name: String = name


  override def toString = s"A(${_id}, ${_name})"
}

/**
  *
  * 继承类同时调用构造函数
  *
  */

class B(id: String, name: String, gender: String) extends A(id, name) {

  println("B的默认构造函数")

  val _gender: String = gender


  //重写父类的方法
  override def toString = s"A(${_id}, ${_name}，${_gender})"
}

